package com.itheima.consumer.mq;

import com.itheima.consumer.constant.MqExChange;
import com.itheima.consumer.constant.MqQueue;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author czt
 * @version 1.0
 * @since 2024/11/7
 */
@Component
public class FanoutExChangeBinding {

    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange(MqExChange.F_TEST);
    }

    @Bean
    public Queue queue1() {
        return new Queue(MqQueue.TEST_1);
    }

    @Bean
    public Binding fanoutExchangeBinding1(Queue queue1,FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(queue1).to(fanoutExchange);
    }

    @Bean
    public Queue queue2() {
        return new Queue(MqQueue.TEST_2);
    }

    @Bean
    public Binding fanoutExchangeBinding2(Queue queue2,FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(queue2).to(fanoutExchange);
    }
}
